//
//  MASConstraintMaker_yjw.h
//  Masonry
//
//  Created by Jonas Budelmann on 20/07/13.
//  Copyright (c) 2013 cloudling. All rights reserved.
//

#import "MASConstraint_yjw.h"
#import "MASUtilities_yjw.h"

typedef NS_OPTIONS(NSInteger, MASAttribute_yjw) {
    MASAttribute_yjwLeft = 1 << NSLayoutAttributeLeft,
    MASAttribute_yjwRight = 1 << NSLayoutAttributeRight,
    MASAttribute_yjwTop = 1 << NSLayoutAttributeTop,
    MASAttribute_yjwBottom = 1 << NSLayoutAttributeBottom,
    MASAttribute_yjwLeading = 1 << NSLayoutAttributeLeading,
    MASAttribute_yjwTrailing = 1 << NSLayoutAttributeTrailing,
    MASAttribute_yjwWidth = 1 << NSLayoutAttributeWidth,
    MASAttribute_yjwHeight = 1 << NSLayoutAttributeHeight,
    MASAttribute_yjwCenterX = 1 << NSLayoutAttributeCenterX,
    MASAttribute_yjwCenterY = 1 << NSLayoutAttributeCenterY,
    MASAttribute_yjwBaseline = 1 << NSLayoutAttributeBaseline,

    MASAttribute_yjwFirstBaseline = 1 << NSLayoutAttributeFirstBaseline,
    MASAttribute_yjwLastBaseline = 1 << NSLayoutAttributeLastBaseline,
    
#if TARGET_OS_IPHONE || TARGET_OS_TV
    
    MASAttribute_yjwLeftMargin = 1 << NSLayoutAttributeLeftMargin,
    MASAttribute_yjwRightMargin = 1 << NSLayoutAttributeRightMargin,
    MASAttribute_yjwTopMargin = 1 << NSLayoutAttributeTopMargin,
    MASAttribute_yjwBottomMargin = 1 << NSLayoutAttributeBottomMargin,
    MASAttribute_yjwLeadingMargin = 1 << NSLayoutAttributeLeadingMargin,
    MASAttribute_yjwTrailingMargin = 1 << NSLayoutAttributeTrailingMargin,
    MASAttribute_yjwCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins,
    MASAttribute_yjwCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins,

#endif
    
};

/**
 *  Provides factory methods for creating MASConstraint_yjw.
 *  Constraints are collected until they are ready to be installed
 *
 */
@interface MASConstraintMaker_yjw : NSObject

/**
 *	The following properties return a new MASViewConstraint_yjw
 *  with the first item set to the makers associated view and the appropriate MASViewAttribute_yjw
 */
@property (nonatomic, strong, readonly) MASConstraint_yjw *left;
@property (nonatomic, strong, readonly) MASConstraint_yjw *top;
@property (nonatomic, strong, readonly) MASConstraint_yjw *right;
@property (nonatomic, strong, readonly) MASConstraint_yjw *bottom;
@property (nonatomic, strong, readonly) MASConstraint_yjw *leading;
@property (nonatomic, strong, readonly) MASConstraint_yjw *trailing;
@property (nonatomic, strong, readonly) MASConstraint_yjw *width;
@property (nonatomic, strong, readonly) MASConstraint_yjw *height;
@property (nonatomic, strong, readonly) MASConstraint_yjw *centerX;
@property (nonatomic, strong, readonly) MASConstraint_yjw *centerY;
@property (nonatomic, strong, readonly) MASConstraint_yjw *baseline;

@property (nonatomic, strong, readonly) MASConstraint_yjw *firstBaseline;
@property (nonatomic, strong, readonly) MASConstraint_yjw *lastBaseline;

#if TARGET_OS_IPHONE || TARGET_OS_TV

@property (nonatomic, strong, readonly) MASConstraint_yjw *leftMargin;
@property (nonatomic, strong, readonly) MASConstraint_yjw *rightMargin;
@property (nonatomic, strong, readonly) MASConstraint_yjw *topMargin;
@property (nonatomic, strong, readonly) MASConstraint_yjw *bottomMargin;
@property (nonatomic, strong, readonly) MASConstraint_yjw *leadingMargin;
@property (nonatomic, strong, readonly) MASConstraint_yjw *trailingMargin;
@property (nonatomic, strong, readonly) MASConstraint_yjw *centerXWithinMargins;
@property (nonatomic, strong, readonly) MASConstraint_yjw *centerYWithinMargins;

#endif

/**
 *  Returns a block which creates a new MASCompositeConstraint_yjw with the first item set
 *  to the makers associated view and children corresponding to the set bits in the
 *  MASAttribute_yjw parameter. Combine multiple attributes via binary-or.
 */
@property (nonatomic, strong, readonly) MASConstraint_yjw *(^attributes)(MASAttribute_yjw attrs);

/**
 *	Creates a MASCompositeConstraint_yjw with type MASCompositeConstraint_yjwTypeEdges
 *  which generates the appropriate MASViewConstraint_yjw children (top, left, bottom, right)
 *  with the first item set to the makers associated view
 */
@property (nonatomic, strong, readonly) MASConstraint_yjw *edges;

/**
 *	Creates a MASCompositeConstraint_yjw with type MASCompositeConstraint_yjwTypeSize
 *  which generates the appropriate MASViewConstraint_yjw children (width, height)
 *  with the first item set to the makers associated view
 */
@property (nonatomic, strong, readonly) MASConstraint_yjw *size;

/**
 *	Creates a MASCompositeConstraint_yjw with type MASCompositeConstraint_yjwTypeCenter
 *  which generates the appropriate MASViewConstraint_yjw children (centerX, centerY)
 *  with the first item set to the makers associated view
 */
@property (nonatomic, strong, readonly) MASConstraint_yjw *center;

/**
 *  Whether or not to check for an existing constraint instead of adding constraint
 */
@property (nonatomic, assign) BOOL updateExisting;

/**
 *  Whether or not to remove existing constraints prior to installing
 */
@property (nonatomic, assign) BOOL removeExisting;

/**
 *	initialises the maker with a default view
 *
 *	@param	view	any MASConstraint_yjw are created with this view as the first item
 *
 *	@return	a new MASConstraintMaker_yjw
 */
- (id)initWithView:(MAS_YJW_VIEW *)view;

/**
 *	Calls install method on any MASConstraint_yjw which have been created by this maker
 *
 *	@return	an array of all the installed MASConstraint_yjw
 */
- (NSArray *)install;

- (MASConstraint_yjw * (^)(dispatch_block_t))group;

@end
